<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <table border="1" width="500px" height="30px" align="center">
            <caption><h4>欢迎光临_vue开发的收银系统_水果店</h4></caption>
            <tr align="center">
                <td><h3>苹果10￥/斤，折扣 8折</h3></td>
            </tr>
            <tr align="center">
                <td>请输入你要购买的斤数 <input type="text" v-model.number="total"></td>
            </tr>
            <tr align="center">
                <td><button @click="price">结账买单~</button></td>
            </tr>
            <tr align="center">
                <td>结账单：总价：{{totalPrice}}￥元 折扣后：{{discountPrice}}￥元 省了：{{savePrice}}￥元</td>
            </tr>
        </table>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        const app = new Vue({
            el:'#app',
            data:{
                total:0,
                totalPrice:0,
                discountPrice:0,
                savePrice:0
            },
            methods:{
                price(){
                    this.totalPrice = this.total * 10
                    this.discountPrice = this.total * 8
                    this.savePrice = this.totalPrice - this.discountPrice 
                }
            }
        })
    </script>
</body>

</html>